/**
 * @合并字符串数组
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>

void concat(char result[], const char s1[], int n1, const char s2[], int n2);

int main(int argc, char *argv[]) {
	const char s1[5] = {'w', 'a', 'n', 'g', ' '};
	const char s2[6] = {'w', 'o', 'r', 'k', 's', '.'};

	char s3[11];

	concat(s3, s1, 5, s2 ,6);

	for (int i=0; i<11; i++) {
		printf("%c", s3[i]);
	}

	printf("\n");
	return 0;
}

void concat(char result[], const char s1[], int n1, const char s2[], int n2) {
	for (int i=0; i<n1; i++) {
		result[i] = s1[i];
	}

	for (int j=0; j<n2; j++) {
		result[n1+j] = s2[j];
	}
}
